﻿using System;
using System.Collections.Generic;

namespace StackExchange.Redis.Extensions.CacheManager
{
    public static class IDatabaseExtension
    {
        public static bool Add<T>(this IDatabase redisDb, string key, T value, TimeSpan expireDate)
        {
            CacheManager cacheManager = new CacheManager(redisDb);
            return cacheManager.Add<T>(key, value, expireDate);
        }

        public static bool Add<T>(this IDatabase redisDb, string key, T value)
        {
            CacheManager cacheManager = new CacheManager(redisDb);
            return cacheManager.Add<T>(key, value);
        }

        public static bool Add<T>(this IDatabase redisDb, string key, string region, T value, TimeSpan expireDate)
        {
            CacheManager cacheManager = new CacheManager(redisDb);
            return cacheManager.Add<T>(key, region, value, expireDate);
        }

        public static bool Add<T>(this IDatabase redisDb, string key, string region, T value)
        {
            CacheManager cacheManager = new CacheManager(redisDb);
            return cacheManager.Add<T>(key, region, value);
        }

        public static bool Set<T>(this IDatabase redisDb, string key, T value, TimeSpan expireDate)
        {
            CacheManager cacheManager = new CacheManager(redisDb);
            return cacheManager.Set<T>(key, value, expireDate);
        }

        public static bool Set<T>(this IDatabase redisDb, string key, T value)
        {
            CacheManager cacheManager = new CacheManager(redisDb);
            return cacheManager.Set<T>(key, value);
        }

        public static bool Set<T>(this IDatabase redisDb, string key, string region, T value, TimeSpan expireDate)
        {
            CacheManager cacheManager = new CacheManager(redisDb);
            return cacheManager.Set<T>(key, region, value, expireDate);
        }

        public static bool Set<T>(this IDatabase redisDb, string key, string region, T value)
        {
            CacheManager cacheManager = new CacheManager(redisDb);
            return cacheManager.Set<T>(key, region, value);
        }

        public static T Get<T>(this IDatabase redisDb, string key, string region)
        {
            CacheManager cacheManager = new CacheManager(redisDb);
            return cacheManager.Get<T>(key, region);
        }

        public static T Get<T>(this IDatabase redisDb, string key)
        {
            CacheManager cacheManager = new CacheManager(redisDb);
            return cacheManager.Get<T>(key);
        }

        public static bool Delete(this IDatabase redisDb, string key, string region)
        {
            CacheManager cacheManager = new CacheManager(redisDb);
            return cacheManager.Delete(key, region);
        }

        public static bool Delete(this IDatabase redisDb, string key)
        {
            CacheManager cacheManager = new CacheManager(redisDb);
            return cacheManager.Delete(key);
        }

        public static bool Exist(this IDatabase redisDb, string key)
        {
            CacheManager cacheManager = new CacheManager(redisDb);
            return cacheManager.Exist(key);
        }

        public static bool Exist(this IDatabase redisDb, string key, string region)
        {
            CacheManager cacheManager = new CacheManager(redisDb);
            return cacheManager.Exist(key, region);
        }

        public static List<string> GetAll(this IDatabase redisDb, string region)
        {
            CacheManager cacheManager = new CacheManager(redisDb);
            return cacheManager.GetAll(region);
        }
    }
}
